<style scoped>
.button {
  background-color: #ccc;
  color: #fff;
  border: none;
  padding: 10px;
  cursor: pointer;
}

.button.active {
  background-color: #f00;
}
.createTaskBtn {
  font-size: 10px;
}
.createTaskBtn:hover {
  color: white;
  background: #276be9;
}
.el-header {
  background-color: #152350c4;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-main {
  background-color: #cbd0da;
  color: #333;

  line-height: 20px;
}
.right-align {
  float: right;
}
</style>
<template>
  <div>
    <el-container>
      <el-header>
        <div>
          <h1 style="color: #ffffff">新建问卷</h1>
        </div>
      </el-header>
      <el-main>
        <!-- <Row type="flex"  align="top" class="code-row-bg" :gutter="25">
      <Col span="16" offset="4">
        <Card>
        <div style="text-align:center">
          <br>
            <h3>{{ $route.query.value }}</h3>
            <br> -->
        <!-- <Radio-group v-model="phone">
            
                <Radio label="ContinuousNumbering">
                    <span>连续编号</span>
                </Radio>
                <Radio label="NumberedTypes">
                    
                    <span>按题型编号</span>
                </Radio>
            </Radio-group> -->
        <!-- <div>
                <br>
                      <Input v-model="describeInformation" type="textarea" :rows="2" placeholder="请输入考试描述信息"></Input>
            
            </div><br> -->
        <!-- </div>
    </Card>
      </Col>
    </Row>
    <br> -->
        <Row type="flex" align="top" class="code-row-bg" :gutter="25">
          <Col span="6">
            <Card :style="{ height: contentHeight + 35 + 'px' }">
              <!-- <div>
              <span >题量</span><span style="margin-left:20px;">总分</span>
          </div> -->

              <div>
                <Tabs type="card">
                  <TabPane label="题型">
                    <Collapse v-model="questionContent">
                      <Panel style="background-color: antiquewhite" name="1">
                        考生信息
                        <p slot="content"></p>
                      </Panel>
                      <Panel style="background-color: antiquewhite" name="2">
                        添加题目

                        <p slot="content">
                          <Button
                            slot="extra"
                            type="default"
                            shape="circle"
                            class="createTaskBtn"
                            style="margin-top: -8px"
                            >单选题</Button
                          >
                          <!-- <Button shape="circle" @click="ChoiceQuestions">单选题</Button> -->
                        </p>
                        <p slot="content">
                          <br />
                          <Button
                            slot="extra"
                            type="default"
                            shape="circle"
                            class="createTaskBtn"
                            style="margin-top: -8px"
                            >多选题</Button
                          >

                          <!-- <Button   shape="circle"  @click="multipleChoiceQuestions">多选题</Button> -->
                        </p>
                        <p slot="content">
                          <br />
                          <Button
                            slot="extra"
                            type="default"
                            shape="circle"
                            class="createTaskBtn"
                            style="margin-top: -8px"
                            >简答题</Button
                          >

                          <!-- <Button   shape="circle"  @click="shortAnswerQuestions">简答题</Button>    -->
                        </p>
                      </Panel>
                    </Collapse>
                  </TabPane>
                  <TabPane label="题库">
                    <Collapse>
                      <div>
                        <p
                          slot="content"
                          v-for="(item, index) in questionBank"
                          :key="index.id"
                          :padding="3"
                        >
                          <br />

                          <Button
                            slot="extra"
                            type="default"
                            shape="circle"
                            style="margin-top: -8px"
                            @click="addInBulkQuestions(index, questionBank)"
                            ><Icon type="ios-list"></Icon>{{ item.name }}</Button
                          >
                        </p>
                      </div>

                      <!-- <p slot="content">
                          <br />
                          <Button
                            slot="extra"
                            type="default"
                            shape="circle"
                            class="createTaskBtn"
                            style="margin-top: -8px"
                            @click="addInBulkQuestions"
                            >批量添加题目</Button
                          >

                        
                        </p> -->
                    </Collapse>
                  </TabPane>
                </Tabs>
                <!-- <Button type="default" @click="answerPage">预览</Button> -->
                <!-- <div
            v-for="(item, index) in questionCreated"
            :key="index.questionId"
            :padding="3" 
          > -->
                <div>
                  <!-- <span
              style="padding: 5px; cursor: pointer"
              
            >
              <strong
                style="color: #57a3f3"
                >
                {{ 1111 }}</strong
              >
            </span> -->
                </div>
              </div>
            </Card>
          </Col>

          <Col span="18">
            <div :style="{ height: contentHeight + 35 + 'px' }" style=" background-color: #ffffff; overflow: auto">
              <div style="text-align: center">
                <div class="right-align">
                  <Button type="success" @click="addTest">完成编辑</Button>
                </div>
                <br />
                <br />
                <h1>{{ $route.query.value }}</h1>
                <br /><br /><br />
                <div style="text-align: left; margin-left: 50px; font-size: 16px">
                  <Button @click="addQuestionnaireDescription" type="text"
                    >添加问卷说明</Button
                  >
                  <br />
                  <span style="margin-left: 20px">{{
                    addQuestionnaireDescriptionContent
                  }}</span>
                </div>
                <el-divider></el-divider>
              </div>
              <div v-for="(item, index) in singleSelectedQuestionList" :key="index">
                <Card style="height: 350px">
                  <div>
                    <h6 style="position: absolute; left: 10px">
                      <div>
                        <span style="font-size: 16px;">单选题</span
                        ><Input
                          v-model="singleSelectScore"
                          style="width: 40px; margin-left: 20px;"
                        ></Input
                        ><span style="margin-left: 5px; font-size: 16px;">分</span>
                      </div>
                    </h6>
                    <br />
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.stem }}</span>
                  </div>
                  <br />
                  <div v-for="(opt, index) in item.options" :key="index">
                    <div>
                      <p>{{ opt }}</p>
                    </div>

                    <!-- <Input v-model="optionA" style="width: 300px; margin-left: 20px">{{
                      opt
                    }}</Input> -->
                  </div>           
                  <br /><br /><br />
                  <div style="position: absolute; left: 10px">
                    <span>正确答案：{{ item.answer }}</span>
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.analysis }}</span>
                  </div>
                  <br />
                </Card>
              </div>
              <div v-for="(item, index) in fillBlankSelectedQuestionList" :key="index">
                <Card style="height: 350px">
                  <div>
                    <h6 style="position: absolute; left: 10px">
                      <div>
                        <span style="font-size: 16px; ">填空题</span
                        ><Input
                          v-model="fillBlankScore"
                          style="width: 40px; margin-left: 20px"
                        ></Input
                        ><span style="margin-left: 5px; font-size: 16px">分</span>
                      </div>
                    </h6>
                    <br />
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.stem }}</span>
                    <!-- <Input v-model="questionContent" type="textarea" :rows="3">{{
                      item.stem
                    }}</Input> -->
                  </div>
                  <br />
                  <br /><br /><br />
                  <div style="position: absolute; left: 10px">
                    <span>正确答案：{{ item.answer }}</span>
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.analysis }}</span>
                  </div>
                  <br />
                </Card>
              </div>
              <div v-for="(item, index) in judgementSelectedQuestionList" :key="index">
                <Card style="height: 350px">
                  <div>
                    <h6 style="position: absolute; left: 10px">
                      <div>
                        <span style="font-size: 16px;">判断题</span
                        ><Input
                          v-model="judgementScore"
                          style="width: 40px; margin-left: 20px"
                        ></Input
                        ><span style="margin-left: 5px;font-size: 16px">分</span>
                      </div>
                    </h6>
                    <br />
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.stem }}</span>
                  </div>
                  <br />
                  <br /><br /><br />
                  <div style="position: absolute; left: 10px">
                    <span>正确答案：{{ item.answer }}</span>
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.analysis }}</span>
                  </div>
                  <br />
                </Card>
              </div>
              <div v-for="(item, index) in quesAndAnswerSelectedQuestionList" :key="index">
                <Card style="height: 350px">
                  <div>
                    <h6 style="position: absolute; left: 10px">
                      <div>
                        <span style="font-size: 16px">简答题</span
                        ><Input
                          v-model="quesAndAnswerScore"
                          style="width: 40px; margin-left: 20px"
                        ></Input
                        ><span style="margin-left: 5px;font-size: 16px">分</span>
                      </div>
                    </h6>
                    <br />
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.stem }}</span>
                  </div>
                  <br />
                  <br /><br /><br />
                  <div style="position: absolute; left: 10px">
                    <span>正确答案：{{ item.answer }}</span>
                  </div>
                  <br /><br />
                  <div>
                    <span>{{ item.analysis }}</span>
                  </div>
                  <br />
                </Card>
              </div>
              <Card v-show="showChoiceQuestions" style="height: 625px">
                <div>
                  <h6 style="position: absolute; left: 10px">
                    <span>单选题</span
                    ><Input v-model="Score" style="width: 40px; margin-left: 20px"></Input
                    ><span style="margin-left: 5px">分</span>
                  </h6>
                  <br />
                </div>
                <br /><br />
                <div>
                  <Input
                    v-model="questionContent"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入题干信息"
                  ></Input>
                </div>
                <br />
                <div style="position: absolute; left: 10px">
                  <Button style="left: 10px" @click="correctAnswerA" shape="circle"
                    >A</Button
                  ><Input
                    v-model="optionA"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button style="left: 10px" @click="correctAnswerB" shape="circle"
                    >B</Button
                  ><Input
                    v-model="optionB"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button style="left: 10px" @click="correctAnswerC" shape="circle"
                    >C</Button
                  ><Input
                    v-model="optionC"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button style="left: 10px" @click="correctAnswerD" shape="circle"
                    >D</Button
                  ><Input
                    v-model="optionD"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <span>正确答案：{{ ChoiceQuestionsAnswer }}</span>
                </div>
                <br /><br />
                <div>
                  <Input
                    v-model="answerKey"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入答案解析"
                  ></Input>
                </div>
                <br />
              </Card>
              <Card v-show="multipleShowChoiceQuestions" style="height: 625px">
                <div>
                  <h6 style="position: absolute; left: 10px">
                    <span>多选题</span
                    ><Input v-model="Score" style="width: 40px; margin-left: 20px"></Input
                    ><span style="margin-left: 5px">分</span>
                  </h6>
                  <br />
                </div>
                <br /><br />
                <div>
                  <Input
                    v-model="multipleQuestionContent"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入题干信息"
                  ></Input>
                </div>
                <br />
                <div style="position: absolute; left: 10px">
                  <Button
                    style="left: 10px"
                    @click="multipleCorrectAnswerA"
                    shape="circle"
                    >A</Button
                  ><Input
                    v-model="optionA"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button
                    style="left: 10px"
                    @click="multipleCorrectAnswerB"
                    shape="circle"
                    >B</Button
                  ><Input
                    v-model="optionB"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button
                    style="left: 10px"
                    @click="multipleCorrectAnswerC"
                    shape="circle"
                    >C</Button
                  ><Input
                    v-model="optionC"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <Button
                    style="left: 10px"
                    @click="multipleCorrectAnswerD"
                    shape="circle"
                    >D</Button
                  ><Input
                    v-model="optionD"
                    placeholder="请输入..."
                    style="width: 300px; margin-left: 20px"
                  ></Input>
                </div>
                <br /><br /><br />
                <div style="position: absolute; left: 10px">
                  <span>正确答案：{{ multipleChoiceQuestionsAnswer }}</span>
                </div>
                <br /><br />
                <div>
                  <Input
                    v-model="answerKey"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入答案解析"
                  ></Input>
                </div>
                <br />
              </Card>
              <Card v-show="shortAnswer" style="height: 325px">
                <div>
                  <h6 style="position: absolute; left: 10px">
                    <span>简答题</span
                    ><Input v-model="Score" style="width: 40px; margin-left: 20px"></Input
                    ><span style="margin-left: 5px">分</span>
                  </h6>
                  <br />
                </div>
                <br /><br />
                <div>
                  <Input
                    v-model="multipleQuestionContent"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入题干信息"
                  ></Input>
                </div>
                <br />
                <div>
                  <Input
                    v-model="answerKey"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入答案"
                  ></Input>
                </div>
                <br />
              </Card>
            </div>
            <br />
          </Col>
        </Row>
      </el-main>
    </el-container>
    <!-- <el-form  v-show=addQuestionnaireDescriptionShow label-width="80px">
      <el-form-item label="问卷说明">
        <el-input v-model="QuestionnaireDescription"></el-input>
      </el-form-item>
    </el-form> -->
    <Modal v-model="addQuestionnaireDescriptionShow" title="填写问卷说明">
      <Form :label-width="80">
        <FormItem label="描述信息：">
          <Input
            type="textarea"
            :rows="3"
            v-model="addQuestionnaireDescriptionContent"
          ></Input>
        </FormItem>
      </Form>
    </Modal>
    <Modal
      @on-ok="addQuestions"
      width="1000px"
      v-model="addInBulkQuestionsShow"
      title="从我的题库添加"
    >
      <div style="height: 650px">
        <Row :gutter="16">
          <Col span="8">
            <Card style="height: 600px">
              <div style="height: 80%">
                <p>问卷列表</p>
                <Button class="createTaskBtn" long @click="selectChoiceQuestion"
                  >单选题</Button
                >
                <Button class="createTaskBtn" long @click="selectFillBlankQuestions"
                  >填空题</Button
                >
                <Button class="createTaskBtn" long @click="selectJudgementQuestions"
                  >判断题</Button
                >
                <Button class="createTaskBtn" long @click="selectShortAnswerQuestions"
                  >简答题</Button
                >
              </div>
            </Card>
          </Col>
          <Col span="16">
            <div style="height: 600px; overflow: auto">
              <div>
                <Checkbox
                  :indeterminate="indeterminate"
                  :value11="checkAll"
                  @click="handleCheckAll"
                  >全选</Checkbox
                >
              </div>
              <div v-for="(ques, index) in selectQuestions" :key="index">
                <Checkbox-group v-model="questionList" @on-change="QuestionListChange">
                  <Card style="width: 80%">
                    <Checkbox class="right-align" :label="index" style="font-size: 16px"
                      >&nbsp;</Checkbox
                    >
                    <span>{{ index + 1 }}. </span> <span>{{ ques.stem }}</span>
                    <!-- <span style="text-align: left">({{ ques.score }}分)</span> -->
                    <p
                      v-if="questionType === 1"
                      v-for="(opt, index) in ques.options"
                      :key="index"
                    >
                      {{ opt }}
                    </p>
                  </Card>
                </Checkbox-group>
              </div>
            </div>
          </Col>
        </Row>
      </div>
    </Modal>
  </div>
</template>
<script>
import { get, post, del, put } from "@/axios";
export default {
  data() {
    return {
      contentHeight: "",
      selectedQuestionList: [],
      questionType: 0,
      questionBank: [],
      questions: [],
      selectQuestions: [],
      singleSelectScore: 5,
      fillBlankScore: 3,
      judgementScore: 2,
      quesAndAnswerScore: 10,
      Score: 5,
      isActive: false,
      ChoiceQuestionsAnswer: "",
      multipleChoiceQuestionsAnswer: [],
      showChoiceQuestions: false,
      multipleShowChoiceQuestions: false,
      shortAnswer: false,
      addQuestionnaireDescriptionShow: false,
      addInBulkQuestionsShow: false,
      describeInformation: "",
      questionContent: "",
      multipleQuestionContent: "",
      createMultipleChoiceQuestion: "",
      multipleQuestionContent: "",
      createShortAnswerQuestion: "",
      optionA: "",
      optionB: "",
      optionC: "",
      optionD: "",
      answerKey: "",
      addQuestionnaireDescriptionContent: "",
      singleSelectedList: [],
      fillBlankSelectedList: [],
      judgementSelectedList: [],
      quesAndAnswerSelectedList: [],
      QuestionnaireDescription: "...",
      indeterminate: false,
      checkAll: false,
      questionList: [],
      singleSelectedQuestionList: [],
      fillBlankSelectedQuestionList: [],
      judgementSelectedQuestionList: [],
      quesAndAnswerSelectedQuestionList: [],
      quesBankId: "",
      sectionJSON: {
        totalScore: 100,

        list: [
          {
            name: "单选题",
            description: "",
            type: "singleSelect",
            size: 0,
            totalScore: 0,
            quesIdList: [],
          },
          {
            name: "填空题",
            description: "",
            type: "fillInBlank",
            size: 0,
            totalScore: 0,
            quesIdList: [],
          },
          {
            name: "判断题",
            description: "",
            type: "judgement",
            size: 0,
            totalScore: 0,
            quesIdList: [],
          },
          {
            name: "简答题",
            description: "",
            type: "quesAndAnswer",
            size: 0,
            totalScore: 0,
            quesIdList: [],
          },
        ],
      },
    };
  },
  created() {

    this.initSize();
  },
  mounted() {
    this.browseQuestionBank();
    window.addEventListener("resize", this.initSize);
  },
  beforeDestroy: function () {
    window.removeEventListener("resize", this.initSize);
  },
  methods: {
    async addTest() {
      let formData = new FormData();
      this.sectionJSON.list[0].size = this.singleSelectedList.length;
      this.sectionJSON.list[0].totalScore =
        this.singleSelectedList.length * this.singleSelectScore;
      this.sectionJSON.list[1].size = this.fillBlankSelectedList.length;
      this.sectionJSON.list[1].totalScore =
        this.fillBlankSelectedList.length * this.fillBlankScore;
      this.sectionJSON.list[2].size = this.judgementSelectedList.length;
      this.sectionJSON.list[2].totalScore =
        this.judgementSelectedList.length * this.judgementScore;
      this.sectionJSON.list[3].size = this.quesAndAnswerSelectedList.length;
      this.sectionJSON.list[3].totalScore =
        this.quesAndAnswerSelectedList.length * this.quesAndAnswerScore;

      this.sectionJSON.totalScore =
        this.sectionJSON.list[0].totalScore +
        this.sectionJSON.list[1].totalScore +
        this.sectionJSON.list[2].totalScore +
        this.sectionJSON.list[3].totalScore;
      // console.log(this.sectionJSON.list);
      // for(let i=0;i<this.sectionJSON.list.length;){

      // if(this.sectionJSON.list[i].size===0){

      // }

      //   i++;
      // }
      // let newArr = this.sectionJSON.list.filter((item) => !item.size === 0);
      this.sectionJSON.list = this.sectionJSON.list.filter(function (item) {
        // console.log(item.size);
        return item.size !== 0;
      });

      // console.log(this.sectionJSON.list);
      // console.log(JSON.stringify(this.sectionJSON));

      formData.append("name", this.$route.query.value);
      formData.append("description", this.addQuestionnaireDescriptionContent);
      formData.append("sectionJSON", JSON.stringify(this.sectionJSON));
      formData.append("quesBankId", this.quesBankId);

      // console.log(JSON.stringify(this.sectionJSON));
     // console.log(formData);
      try {
        let res = await post("/visualResourceLibrary/questionnaire/test/add", formData);
       // console.log(res.data.data);
       this.$router.push({
            path: "/classTests",
          });
      } catch (e) {
        this.$Message.error("修改失败");
        console.log(e);
      }
    },
    initSize() {
      this.contentHeight = window.innerHeight - 140;
    },
    addQuestions() {
      let selected = 0;
      let i = 0;
      // console.log(this.selectQuestions);
      for (i = 0; i < this.questionList.length; ++i) {
        selected = this.questionList[i];
        // console.log(this.selectQuestions[selected].stem);
        this.selectedQuestionList.push(this.selectQuestions[selected]);
        if (this.questionType === 1) {
          this.singleSelectedQuestionList.push(this.selectQuestions[selected]);
          this.singleSelectedList.push(this.selectQuestions[selected].id);
          this.sectionJSON.list[0].quesIdList.push(this.selectQuestions[selected].id);
        } else if (this.questionType === 2) {
          this.fillBlankSelectedQuestionList.push(this.selectQuestions[selected]);
          this.fillBlankSelectedList.push(this.selectQuestions[selected].id);
          this.sectionJSON.list[1].quesIdList.push(this.selectQuestions[selected].id);
        } else if (this.questionType === 3) {
          this.judgementSelectedQuestionList.push(this.selectQuestions[selected]);
          this.judgementSelectedList.push(this.selectQuestions[selected].id);
          this.sectionJSON.list[2].quesIdList.push(this.selectQuestions[selected].id);
        } else if (this.questionType === 4) {
          this.quesAndAnswerSelectedQuestionList.push(this.selectQuestions[selected]);
          this.quesAndAnswerSelectedList.push(this.selectQuestions[selected].id);
          this.sectionJSON.list[3].quesIdList.push(this.selectQuestions[selected].id);
        }
      }
      // console.log(this.singleSelectedList.length * this.singleSelectScore);
    },
    selectChoiceQuestion() {
      this.indeterminate = false;
      this.checkAll = false;
      this.questionList = [];
      this.questionType = 1;
      this.selectQuestions = this.questions.singleSelect;
    },
    selectFillBlankQuestions() {
      this.indeterminate = false;
      this.checkAll = false;
      this.questionList = [];
      this.questionType = 2;
      this.selectQuestions = this.questions.fillInBlank;
    },
    selectJudgementQuestions() {
      this.indeterminate = false;
      this.checkAll = false;
      this.questionList = [];
      this.questionType = 3;
      this.selectQuestions = this.questions.judgement;
    },
    selectShortAnswerQuestions() {
      this.indeterminate = false;
      this.checkAll = false;
      this.questionList = [];
      this.questionType = 4;
      this.selectQuestions = this.questions.quesAndAnswer;
    },
    handleCheckAll() {
      if (this.indeterminate) {
        this.checkAll = false;
      } else {
        this.checkAll = !this.checkAll;
      }
      this.indeterminate = false;
      if (this.checkAll) {
        this.questionList = this.questions;
      } else {
        this.questionList = [];
      }
    },
    async browseQuestionBank() {
      let page = 0;
      let size = 10;
      try {
        let res = await get(
          "/visualResourceLibrary/questionnaire/quesBank/" + page + "/" + size
        );
        // console.log(res.data.data);
        this.questionBank = res.data.data.content;
        // console.log(this.questionBank);
      } catch (e) {
        this.$Message.error("修改失败");
        console.log(e);
      }
    },
    QuestionListChange(data) {
      if (data.length === this.questions.length) {
        this.indeterminate = false;
        this.checkAll = true;
      } else if (data.length > 0) {
        this.indeterminate = true;
        this.checkAll = false;
      } else {
        this.indeterminate = false;
        this.checkAll = false;
      }
    },
    ChoiceQuestions() {
      // this.showChoiceQuestions=true;
      this.showChoiceQuestions = !this.showChoiceQuestions;
      // this.multipleShowChoiceQuestions=false;
      // this.shortAnswer=false;
    },
    correctAnswerA() {
      this.ChoiceQuestionsAnswer = "";
      this.ChoiceQuestionsAnswer = "A";
    },
    correctAnswerB() {
      this.ChoiceQuestionsAnswer = "";
      this.ChoiceQuestionsAnswer = "B";
    },
    correctAnswerC() {
      this.ChoiceQuestionsAnswer = "";
      this.ChoiceQuestionsAnswer = "C";
    },
    correctAnswerD() {
      this.ChoiceQuestionsAnswer = "";
      this.ChoiceQuestionsAnswer = "D";
    },
    createChoiceQuestion() {
      this.showChoiceQuestions = false;
    },

    multipleChoiceQuestions() {
      this.multipleShowChoiceQuestions = !this.multipleShowChoiceQuestions;
      // this.shortAnswer=false;
      // this.showChoiceQuestions=false;
    },
    multipleCorrectAnswerA() {
      if (!this.multipleChoiceQuestionsAnswer.includes("A")) {
        this.multipleChoiceQuestionsAnswer.push("A"); // 如果元素不存在于数组中，则将其添加到数组中
      }
    },

    multipleCorrectAnswerB() {
      if (!this.multipleChoiceQuestionsAnswer.includes("B")) {
        this.multipleChoiceQuestionsAnswer.push("B"); // 如果元素不存在于数组中，则将其添加到数组中
      }
    },
    multipleCorrectAnswerC() {
      if (!this.multipleChoiceQuestionsAnswer.includes("C")) {
        this.multipleChoiceQuestionsAnswer.push("C"); // 如果元素不存在于数组中，则将其添加到数组中
      }
    },
    multipleCorrectAnswerD() {
      if (!this.multipleChoiceQuestionsAnswer.includes("D")) {
        this.multipleChoiceQuestionsAnswer.push("D"); // 如果元素不存在于数组中，则将其添加到数组中
      }
    },
    shortAnswerQuestions() {
      this.shortAnswer = !this.shortAnswer;
      // this.showChoiceQuestions=false;
      // this.multipleShowChoiceQuestions=false;
    },
    addQuestionnaireDescription() {
      this.addQuestionnaireDescriptionShow = !this.addQuestionnaireDescriptionShow;
    },
    async addInBulkQuestions(index, questionBank) {
      this.addInBulkQuestionsShow = true;
      this.quesBankId = this.questionBank[index].id;
      try {
        let res = await get(
          "/visualResourceLibrary/questionnaire/quesBank/" + questionBank[index].id
        );
        this.questions = res.data.data;
        // console.log(this.questions);
        // console.log(this.questions.singleSelect);
      } catch (e) {
        this.$Message.error("修改失败");
        console.log(e);
      }
    },
  },
};
</script>
